<template>
  <el-dialog
    title="提示！"
    :visible.sync="dialogVisible"
    width="450px"
  >
    <div class="dataBox">
      检测到当前<span
        class="span1"
        :class="inNoticeTime == 1 ? 'span1' : 'span2'"
      >{{ inNoticeTime == 1 ? "正" : "不" }}处于</span>启用时间段内是否需要<span
        class="span1"
        :class="status == 0 ? 'span1' : 'span2'"
      >立刻{{ status == 0 ? "启" : "停" }}用</span>本功能？
    </div>
    <span
      slot="footer"
      class="dialog-footer"
    >
      <el-button
        class="span5"
        @click="dialogVisible = false"
      >否</el-button>
      <el-button
        :class="status == 0 ? 'span4' : 'span3'"
        @click="dataFormSubmit"
      >是，{{ status == 0 ? "启" : "停" }}用</el-button>
    </span>
  </el-dialog>
</template>

<script>
import moment from 'moment'
export default {
  data() {
    return {
      paramKey: "",
      items: null,
      status: 0,
      id: "",
      dialogVisible: false,
      dataForm: {
        name: "",
        startTime: "",
        endTime: "",
      },
      s: '',
      e: '',
      inNoticeTime: null
    };
  },
  methods: {
    open(item) {
      console.log(item);
      item.immediate = 1;
      this.dialogVisible = true
      this.items = item;
      this.status = this.items.status;
      this.items.status = this.items.status == 0 ? 1 : 0;
      this.s = moment().format('YYYY-MM-DD') + ' ' + this.items.startTime
      this.e = moment().format('YYYY-MM-DD') + ' ' + this.items.endTime
      this.inNoticeTime = moment().isBetween(this.s, this.e)
    },
    dataFormSubmit() {
      this.$http({
        url: this.$http.adornUrl(`/platform/noticeNew/updateNoticeNew`),
        method: "post",
        data: this.items,
      })
        .then((res) => {
          this.dialogVisible = false;
          this.$message({
            message: res.msg,
            type: "success",
            duration: 1500,
          });
          this.$parent.getDataList();
        })
        .catch((e) => { });
    },
  },
};
</script>
<style lang="scss" scoped>
.dataBox {
  font-family: HarmonyOS Sans SC, HarmonyOS Sans SC;
  font-weight: 400;
  font-size: 18px;
  color: #333333;
  padding: 0 40px;
  box-sizing: border-box;
  text-indent: 20px;
  line-height: 30px;
  .span1 {
    color: #1890ff;
  }
  .span2 {
    color: #a2170b;
  }
}
::v-deep .span3 {
  background: #a2170b !important;
  border-radius: 10px 10px 10px 10px;
}
::v-deep .span4 {
  background: #1890ff !important;
  border-radius: 10px 10px 10px 10px;
}
.el-button {
  color: #fff;
}
.span5 {
  width: 80px;
  background: rgba(144, 140, 140, 0.8);
  border-radius: 10px 10px 10px 10px;
}
</style>
